package com.example.administrator.readbook.ui.fragment;

import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;

import com.example.administrator.readbook.R;
import com.example.administrator.readbook.base.BaseFragment;
import com.example.administrator.readbook.navigation.MainNavigation;
import com.example.administrator.readbook.ui.RankingActivity;

import java.lang.ref.WeakReference;

/**
 * Created by ShaoGeng on 2018/7/12.
 * email 1002919029@qq.com
 * GitHub https://github.com/shaogeng1994
 */

public class SearchFragment extends BaseFragment {

    private WeakReference navigation = new WeakReference<MainNavigation>(null);
    private LinearLayout rankingLayout;
    private LinearLayout classifyLayout;

    public static Fragment getInstance(MainNavigation navigation) {
        SearchFragment fragment = new SearchFragment();
        fragment.navigation = new WeakReference<MainNavigation>(navigation);
        return fragment;
    }

    @Override
    public View initLayout() {
        View view = View.inflate(getActivity(), R.layout.fragment_search, null);
        view.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
        return view;
    }

    @Override
    public void initViewModel() {

    }

    @Override
    public void initView() {
        rankingLayout = mContentView.findViewById(R.id.search_layout_ranking);
        classifyLayout = mContentView.findViewById(R.id.search_layout_classify);
    }

    @Override
    public void initListener() {
        rankingLayout.setOnClickListener(this);
        classifyLayout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.search_layout_ranking:
                startActivity(new Intent(mContentView.getContext(), RankingActivity.class));
                break;
            case R.id.search_layout_classify:
                break;
            default:
                break;
        }
    }
}
